﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//求和对数
//https://www.nowcoder.com/discuss/651897992093388800?sourceSSR=dynamic
//用哈希表判断x-ai这个键是否存在，值用来表示提供这个的列表该数字出现了多少次，如果键存在ans加上数字的出现次数就是答案了
//和所有的target-num 匹配
public class Soljd2
{


    public int SumNum2(int[] a,int x)//暴力超时，但是允许自己和自己组合，也允许
    {
        int res = 0;

        for (int i = 0; i < a.Length; i++)
        {

            for (int j = 0; j < a.Length; j++)
            {

                if (a[i] + a[j] == x)
                {
                    res++;
                    Console.WriteLine("i:  "+i+ "  j:  " + j);
                }

            }

        }
        return res;

    }
    public int SumNum(int[] a, int x)
    {
        int count = 0;
        //不要边遍历边加入,int1 是value，int2 是这个数字出现的次数
        Dictionary<int, int> res = new Dictionary<int, int>();

        for (int i = 0; i < a.Length; i++)
        {
            if (!res.ContainsValue(a[i]))
            {
                res[i] = a[i];//加入
            }

        }

        for (int i = 0; i < a.Length; i++)
        {
            if (res.ContainsValue(x - a[i]))
            {
                count++;
            }
            if (a[i] + a[i] == x)
            {
                count++;

            }



        }
        return count;

    }
    public int SumNum3(int[] a, int x)//2 2 4,结果是3种组合吗
    {
        int count = 0;
      
        Dictionary<int,int> res = new Dictionary<int,int>();

        for (int i = 0; i < a.Length; i++)
        {
            if (!res.ContainsValue(a[i]))
            {
                res[i] = a[i];//加入
            }
        
        }

        for (int i = 0; i < a.Length; i++)
        {
            if (res.ContainsValue(x-a[i]))
            {
                count++;
            }

            

        }
        return count;

    }

}


public class Programjd2
{
    public static void Mainjd2()
    {
        string line;
        while ((line = System.Console.ReadLine()) != null)
        { // 注意 while 处理多个 case
            string[] tokens = line.Split();
            int n = int.Parse(tokens[0]);
            int x = int.Parse(tokens[1]);
            int[] a =new int[n];

            line = System.Console.ReadLine();
           tokens = line.Split();
            for (int i = 0; i < tokens.Length; i++)
            {
                a[i]= int.Parse(tokens[i]);
            }


            Soljd2 soljd2 = new Soljd2();
          int res=  soljd2.SumNum(a, x);
            Console.WriteLine(res);


        }
    }
}